<?php
require( 'mofachi.LocationData.php' );
class Location {
	private $locationData;
	private $is_loaded;
	public function __get( $key ) {
		return $this->locationData->$key;
	}
	public function __set( $key, $value ) {
		switch( $key ) {
			case "location_id":
				if( !$this->is_loaded ) {
					$this->locationData->baby_id = $value;
					break;
				}
			default:
				$this->locationData->$key = $value;
		}
	}
	public function __construct() {
		$this->locationData = new locationData();
		$this->is_loaded = false;
	}
	public function loadByID() {
		if( !$this->location_id ) {
			return false;
		}		
		$this->is_loaded = $this->locationData->loadByID();
		return $this->is_loaded;
	}
	public function loadByRegionCode() {
		if( !$this->region_code ) {
			return false;
		}		
		$this->is_loaded = $this->locationData->loadByRegionCode();
		return $this->is_loaded;
	}
	public function loadByCityCode() {
		if( !$this->city_code ) {
			return false;
		}		
		$this->is_loaded = $this->locationData->loadByCityCode();
		return $this->is_loaded;
	}
}
?>